import React from 'react';
import { Card, Space, Table } from 'antd';
import './index.css';

export default function StudentTable(props) {
    console.log(props, 'list组件')
    const columns = [
        {
            title: '学号',
            dataIndex: 'sNo',
            align: 'center',
            key: 'sNo'
        },
        {
            title: '姓名',
            dataIndex: 'name',
            align: 'center',
            key: 'name'
        },
        {
            title: '性别',
            dataIndex: 'sex',
            align: 'center',
            key: 'sex',
            render: text => <span>{text === 0 ? '男' : '女'}</span>
        },
        {
            title: '电话',
            dataIndex: 'phone',
            align: 'center',
            key: 'phone'
        },
        {
            title: '邮箱',
            dataIndex: 'email',
            align: 'center',
            key: 'email'
        },
        {
            title: '出生年份',
            dataIndex: 'birth',
            align: 'center',
            key: 'birth'
        },
        {
            title: '地址',
            dataIndex: 'address',
            align: 'center',
            key: 'address',
        },
        {
            title: '操作',
            key: 'action',
            align: 'center',
            render: (text, record, index) => (
                <Space size="middle">
                    <a>Delete</a>
                    <a  onClick={e => {
                        if (props.handleClick) {
                            props.handleClick(record);
                        }
                    }}>Check</a>
                </Space>
            )
        }
    ];

    return (
        <div>
            <Card className='tableCard'>
                <Table columns={columns} dataSource={props.data} pagination={false} rowKey={record => record.id} />
            </Card>
        </div>
    )
}
